import java.util.ArrayList;
import java.util.List;

public class Solution95 {

    public static class TreeNode {
        int val;
        TreeNode left;
        TreeNode right;

        TreeNode() {
        }

        TreeNode(int val) {
            this.val = val;
        }

        TreeNode(int val, TreeNode left, TreeNode right) {
            this.val = val;
            this.left = left;
            this.right = right;
        }
    }

    public List<TreeNode> generateTrees(int n) {
        return dfs(1,n);
    }

    private List<TreeNode> dfs(int start, int end) {
        List<TreeNode> treeNodes=new ArrayList<>();
        for (int i=start;i<=end;i++){
            List<TreeNode> left=dfs(start,i-1);
            List<TreeNode> right=dfs(i+1,end);
            if (left.size()==0){
                left.add(null);
            }
            if (right.size()==0){
                right.add(null);
            }
            for (TreeNode node1 : left) {
                for (TreeNode node2 : right) {
                    treeNodes.add(new TreeNode(i,node1,node2));
                }
            }
        }
        return treeNodes;
    }

    public static void main(String[] args) {
        System.out.println(new Solution95().generateTrees(3).size());
    }
}
